<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // Array.prototype.myReverse = function () {
        //     var a1 = [] //暂存列表
        //     for (var i = this.length-1; i>=0 ; i--){
        //         a1.push(this[i])
        //     }
        //     return a1
        // }

        // var arr1 = [1,2,3,4]
        // console.log(arr1.myReverse())

        // Array.prototype.myConcat = function (a) {
        //     if(a.constructor==Number){
        //         this.push(a)
        //     }
        //     else
        //     for(var i = 0; i<a.length; i++){
        //         this.push(a[i])
        //     }
        //     return this
        // }

        // var arr3 = [1,2,3,4]
        // var arr4 = [100,200,300,400]
        // console.log(arr3.myConcat(arr4))
        // console.log(arr4.myConcat(1000))

        // Array.prototype.myForEach = function(item,index) {
        //     for(var i=0; i<this.length;i++){
        //         item = this[i]
        //         index = i
        //         console.log(item + ' : '+ i)
        //     }
        //     return 0
        // }
        // var arr5 = [100,200,300,400]
        // arr5.myForEach()

        var arr7 = [100,200,300,400,500]
        Array.prototype.mySome = function (callback){
            for (var i = 0 ; i<this.length;i++){
                callback(this[i],i)
            }
        }

        console.log(
            arr7.mySome(function(item,index){
                return item > 300
            })
        )
    </script>
</body>
</html>